package com.mrd.modules.quartz;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

/**
 * 定时器配置
 * 
 * @author han
 *
 */
@Configuration
@EnableScheduling
public class QuartzSchedule {

  @Autowired
  private MyJobFactory myJobFactory;

  @Bean
  public SchedulerFactoryBean schedulerFactoryBean() throws IOException {
    SchedulerFactoryBean factory = new SchedulerFactoryBean();
    factory.setOverwriteExistingJobs(true);
    // 延时启动
    factory.setStartupDelay(20);
    // // 加载quartz数据源配置
    // factory.setQuartzProperties(quartzProperties());
    // 自定义Job Factory，用于Spring注入
    factory.setJobFactory(myJobFactory);
    return factory;
  }

}
